package com.mwf.domain.activity.service;

import com.mwf.domain.activity.model.entity.MarketProductEntity;
import com.mwf.domain.activity.model.entity.TrialBalanceEntity;
import com.mwf.domain.activity.service.trial.factory.DefaultActivityStrategyFactory;
import com.mwf.types.design.framework.tree.StrategyHandler;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class IndexGroupBuyMarketServiceImpl implements IIndexGroupBuyMarketService {

    @Resource
    private DefaultActivityStrategyFactory activityStrategyFactory;

    @Override
    public TrialBalanceEntity indexMarketTrial(MarketProductEntity marketProduct) throws Exception {
        StrategyHandler<MarketProductEntity, DefaultActivityStrategyFactory.DynamicContext, TrialBalanceEntity> strategiedHandler = activityStrategyFactory.strategyHandler();
        TrialBalanceEntity trialBalanceEntity = strategiedHandler.apply(marketProduct, new DefaultActivityStrategyFactory.DynamicContext());

        return trialBalanceEntity;
    }
}
